#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define debug(x) cerr<<#x<<':'<<x<<endl
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const int N=5e5+5,inf=1e9;
int n,k,a[N],tmp[N],c[N],tot;
int tree[N];
int lowbit(int x){
	return x&(-x);
}
void add(int x,int v){
	for(;x<=tot;x+=lowbit(x)) tree[x]=max(tree[x],v);
}
int ask(int x){
	int res=-inf;
	for(;x;x-=lowbit(x)) res=max(res,tree[x]);
	return res;
}
bool check(int x){
	for(int i=1;i<=tot;i++) tree[i]=-inf;
	add(1,1);
	int p=tot;
	for(int i=1;i<=tot;i++){
		while(p&&tmp[i]+tmp[p]>x) p--;
		c[i]=p;
	}
	for(int i=2;i<=n;i++){
		if(tmp[a[i]]+tmp[a[1]]>x) continue;
		int res=ask(c[a[i]])+1;
		add(a[i],res);
		if(res>=k) return 1;
	}
	return 0;
}
signed main(){
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	cin>>n>>k;
	int p=1;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]<=a[p]) p=i;
	}
	for(int i=p;i<=n;i++) tmp[++tot]=a[i];
	for(int i=1;i<p;i++) tmp[++tot]=a[i];
	for(int i=1;i<=n;i++) a[i]=tmp[i];
	sort(tmp+1,tmp+tot+1);
	int l=tmp[1]+tmp[2],r=tmp[n-1]+tmp[n];
	tot=unique(tmp+1,tmp+tot+1)-tmp-1;
	for(int i=1;i<=n;i++) a[i]=lower_bound(tmp+1,tmp+n+1,a[i])-tmp;
	int res=-1;
	while(l<=r){
		int mid=(l+r)/2;
		if(check(mid)) res=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<res;
	return 0;
}

